<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="/pages/mastertemplate/MasterPage.xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui">
	<ui:define name="content">
		<p:panel header="#{msg.soquy_title}">
			<h:form>
				<p:fileUpload widgetVar="fileuplaod_wgt"
					fileUploadListener="#{SoQuyBean.handleFileUpload}"
					mode="advanced" dragDropSupport="false" update=":soQuyForm"
					sizeLimit="100000" fileLimit="1"
					allowTypes="/(\.|\/)(#{DataConfigBean.fileExtensionPattern})$/" />
			</h:form>
			<h:form>
				<p:commandButton style="width:150px;float: left;margin-top:10px;"
					value="#{msg.Button_export}"
					actionListener="#{SoQuyBean.downloadFileCSV}" ajax="false">
					<p:fileDownload value="#{SoQuyBean.file}" />
				</p:commandButton>
			</h:form>

			<h:form id="soQuyForm">
				<p:growl id="growforFile" autoupdate="true"
					life="#{DataConfigBean.growlShow}" />
					<p:panelGrid id="tonQuyPanel" columns="2" style="width: 100%; margin: 45px auto;">
					<f:facet name="header">
						<h:outputText value="#{msg.tonQuy}"/>
					</f:facet>
					<h:outputLabel for="tongThu" value="#{msg.tongThuLabel}"></h:outputLabel>
					<h:outputText id="tongThu" value="$ 500,000,000.00"></h:outputText>
					<h:outputLabel for="tongChi" value="#{msg.tongChiLabel}"></h:outputLabel>
					<h:outputText id="tongChi" value="$ 100,000,000.00"></h:outputText>
					<h:outputLabel for="tonQuy" value="#{msg.tonQuyLabel}"></h:outputLabel>
					<h:outputText id="tonQuy" value="$ 400,000,000.00"></h:outputText>
					</p:panelGrid>
				<p:dataTable id="dataTable" var="soquy"
					value="#{SoQuyBean.soQuyModel}" lazy="true" paginator="true"
					rows="10"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="10,20,50,100"
					style="width: 100%; margin: 45px auto;">

					<f:facet name="header">
						<h:outputText value="#{msg.danhSachLenhThuChi}"
							styleClass="tableHeader" />
						<div style="margin: -4px -11px 5px; float: right;">
							<p:commandButton style="height: 25px"
								update=":addSoQuyForm:display" value="+ thêm mới"
								rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
								actionListener="#{SoQuyBean.notifyAdd}"
								onclick="SoQuyDialog.show();">
							</p:commandButton>
						</div>

					</f:facet>

					<p:column headerText="#{msg.maPhieuThuChi}"></p:column>

					<p:column headerText="#{msg.ngayThucHien}"></p:column>

					<p:column headerText="#{msg.soTien}"></p:column>
					
					<p:column style="width:60px;text-align: center;"
						headerText="#{msg.table_actions}">
						<p:commandButton styleClass="smallButton"
							icon="ui-icon ui-icon-pencil" update=":addSoQuyForm:display"
							rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
							action="#{SoQuyBean.notifyEdit(khohang)}"
							oncomplete="SoQuyDialog.show();">

						</p:commandButton>
						<p:commandButton style="margin-left: 5px" styleClass="smallButton"
							icon="ui-icon ui-icon-trash"
							rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
							oncomplete="confirmRemove.show();">
							<f:setPropertyActionListener value="#{khohang}"
								target="#{SoQuyBean.selectedSoQuy}" />
						</p:commandButton>
					</p:column>

				</p:dataTable>

				<p:dialog id="confirmRemove" header="#{msg.confirm}"
					widgetVar="confirmRemove" resizable="false">
					<table>
						<tr>
							<td><h:outputText value="#{msg.confirm_text}:" /></td>
							<td align="right"><p:commandButton value="#{msg.okButton}"
									actionListener="#{SoQuyBean.removeSoQuy}"
									update=":soQuyForm" oncomplete="confirmRemove.hide();" /></td>
						</tr>

					</table>
				</p:dialog>
			</h:form>
			<h:form id="addSoQuyForm">
				<p:dialog id="dialog" header="Thêm mới/ Sửa" modal="true"
					widgetVar="SoQuyDialog" resizable="false">

					<p:panel id="display">
						<table>
							
							<tr>

								<td></td>
								<td align="right"><p:commandButton value="Lưu"
										actionListener="#{SoQuyBean.save}"
										update=":soQuyForm :addSoQuyForm:display"
										oncomplete="if(args.opSuccess) SoQuyDialog.hide()"></p:commandButton></td>
							</tr>
						</table>
					</p:panel>
				</p:dialog>
			</h:form>
			
		</p:panel>
	</ui:define>
</ui:composition>
